package com.core.cloudcommon.config;

import com.core.cloudcommon.utils.SnowflakeIdGenerator;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author =====Lqj=====
 * @className SnowflakeConfig
 * @description 雪花ID生成器配置类
 * @create 2024/12/17 10:30
 **/
@Slf4j
@Configuration
public class SnowflakeConfig {

    /**
     * 雪花ID生成器Bean
     */
    @Bean
    @ConditionalOnMissingBean
    public SnowflakeIdGenerator snowflakeIdGenerator() {
        SnowflakeIdGenerator generator = new SnowflakeIdGenerator();
        log.info("雪花ID生成器初始化完成");
        log.info(generator.getModuleStatistics());
        return generator;
    }
}
